﻿using System;
using System.Xml.Linq;
using Microsoft.Http;
using System.Configuration;

namespace WoodbaseVideoRental.UserControls
{
    public partial class MovieList : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            using (HttpClient client = new HttpClient(ConfigurationManager.AppSettings["webservicebasepath"]))
            {
                using (HttpResponseMessage msg = client.Get("Movies"))
                {
                    msg.EnsureStatusIsSuccessful();
                    XElement docSource = msg.Content.ReadAsXElement();
                    docSource.Add(new XAttribute("type", "normal"));
                    xmlMovieList.DocumentContent = docSource.ToString();
                    xmlMovieList.TransformSource = Server.MapPath("/Styles/XSLT/LatestMovies.xslt");
                    xmlMovieList.DataBind();
                }
            }
        }
    }
}